class CanclePromise {
  constructor(shiajin, signal) {
    let _reject = null;
    let _resovle = null;
    let isExce = false;

    let a = new Promise((resovle, reject) => {
      _reject = reject;
      _resovle = (val) => {
        isExce = true;
        resovle(val);
      };
      shiajin(_resovle, reject);
    });

    if (signal) {
      signal.addEventListener("abort", () => {
        if (isExce) {
          return;
        }
    
        let error = new DOMException("RRRRRRRRR")
        _reject(error);
      });
    }
    return a;
  }
}

export default CanclePromise;

